<template>
  <div>
    <p>{{name}}</p>
    <button @click="change">变一下</button>
    <p>{{obj.age}}</p>
    <button @click="changeAge">过六十大寿了</button>
  </div>
</template>

<script>
// 数据响应式
// 1. 导入ref函数
import { ref} from 'vue'
export default {
  setup() {
    let name = ref('志斌')
    const obj = ref({
      age: 60
    })
    const change = () => {
      console.log(name)
      name.value = '凯亮'
    }
    const changeAge = () => {
      console.log(obj)
      obj.value.age++
    }
    return {
      name,
      change,
      obj,
      changeAge
    }
  },

}
</script>